package com.lagou.testpool;

import com.lagou.utils.DruidUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author wsl
 * @Date 2021/8/22 22:07
 * @Project_Name mysql
 *
 * 需求 查询 薪资在3000 到 5000之间的员工的姓名
 */
public class DruidTest {

    public static void main(String[] args) throws SQLException {

        //1.获取连接
        Connection con = DruidUtils.getConnection();

        //2.获取statement对象
        Statement statement = con.createStatement();

        //3.执行查询
        String sql = "select ename from employee where salary between 3000 and 5000";
        ResultSet resultSet = statement.executeQuery(sql);

        //4.处理结果集
        while (resultSet.next()){
            String ename = resultSet.getString("ename");
            System.out.println("工资在3000-5000的员工："+ename);
        }

        //5.释放资源
        DruidUtils.close(con,statement,resultSet);
    }
}
